@inject IConfiguration configuration
@using Nekonya
@using Microsoft.AspNetCore.Localization
@using Microsoft.Extensions.Options
@using Microsoft.AspNetCore.Builder
@inject IOptions<RequestLocalizationOptions> LocOptions
@inject Chino.IdentityServer.Services.Localization.IJsonLocalizationService JL

@{
    var requestCulture = Context.Features.Get<IRequestCultureFeature>();
    var cultureItems = LocOptions.Value.SupportedUICultures
        .Select(c => new SelectListItem { Value = c.Name, Text = c.NativeName })
        .OrderBy(item => item.Value)
        .ToList();

    var currentCulture = requestCulture?.RequestCulture?.UICulture;

    //设置语言之后的跳转
    var returnUrl = string.IsNullOrEmpty(Context.Request.Path) ? "~/" : $"~{Context.Request.Path.Value}{(Context.Request.QueryString.HasValue ? Context.Request.QueryString : string.Empty)}";

    //bool IsDashboard()
    //{
    //    var isDashboard = ViewData["_dashboard"];
    //    if (isDashboard != null)
    //        return (bool)isDashboard;
    //    else
    //        return false;
    //}
}

<link rel="stylesheet" href="~/css/chino-dashboard-footer.css" />


<footer class="pt-4 my-md-5 pt-md-5 border-top">
    <div class="copyright">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <span>Copyright &copy; @JL[configuration["Chino:Footer:Copyright"],currentCulture]</span>
                </div>

                <div class="col-md-6">
                    <div class="LocalizationSelecter mt-0 mb-2 mt-md-2 float-md-right float-none">
                        <form id="selectLanguageForm"
                              method="post"
                              asp-page="/Index"
                              asp-page-handler="SetCulture"
                              asp-route-returnUrl="@returnUrl">
                            <select class="form-select form-control"
                                    id="cultureSelect"
                                    name="culture"
                                    asp-for="@requestCulture.RequestCulture.UICulture.Name"
                                    asp-items="cultureItems"></select>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</footer>

<script>
    window.onload = function () {
        var cultureSelect = document.getElementById("cultureSelect");
        var cultureForm = document.getElementById("selectLanguageForm");

        if (cultureSelect && cultureForm) {
            cultureSelect.onchange = function () {
                cultureForm.submit();
            };
        }
    }
</script>